#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;
using tl = tuple < int, int, int >;

ll read() {
	ll x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
const int N = 2e5 + 10;

int n;
ll a[N], scd[N];

void solve() {
	n = in; rep(i, 1, n) a[i] = in;
	scd[n + 1] = 0; per(i, n, 1) scd[i] = __gcd(scd[i + 1], a[i]);
	ll tcd = 0, ans = scd[1];
	rep(i, 1, n) {
		ll vcd = 0;
		rep(j, i + 1, n) {
			ll res = __gcd((__int128)tcd, __gcd((__int128)vcd, __gcd((__int128)scd[j + 1], (__int128)a[i] * a[j])));
			ans = max(ans, res);
			vcd = __gcd(vcd, a[j]);
		}
		tcd = __gcd(tcd, a[i]);
	}
	printf("%lld\n", ans);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	int T = in; while(T--) solve();
	return 0;
}
